package com.tanhua.app.service;

import com.tanhua.api.UserLocationApi;
import com.tanhua.app.exception.BusinessException;
import com.tanhua.app.intercept.UserHolder;
import com.tanhua.model.vo.ErrorResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;
    /**
     * 上报地理位置
     * @param longitude
     * @param latitude
     * @param addrStr
     */
    public void updateLocation(Double longitude, Double latitude, String addrStr) {
        //1.调用Api方法
        Boolean flag = userLocationApi.updateLocation(UserHolder.getUserId(),longitude,latitude,addrStr);

        //2.判断是否上报成功
        if (!flag){
            //失败
            throw new BusinessException(ErrorResult.huanXin2Error());
        }
    }
}
